import news from '../api/news';

import * as actionTypes from '../constants/news';

const bannerList = (data) => ({
  type: actionTypes.GET_BANNER_LIST,
  data: data
});

const newsNoticeList = (data) => ({
  type: actionTypes.GET_NEWS_NOTICE_LIST,
  data: data
});

export const getBannerList = () => {
  return (dispatch) => {
    news.banner().then(res => {
      let data = res.data;
      if(data.state == 1){
        dispatch(bannerList(data.data));
      }
    });
  }
};

export const getNewsNoticeList = (columnId, page, pageSize) => {
  return (dispatch) => {
    news.newsNotice(columnId, page, pageSize).then(res => {
      let data = res.data;
      if(data.state == 1){
        dispatch(newsNoticeList(data.data));
      }
    });
  }
};

